<template>
  <div>
    <button @click="send">{{ content }}</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      content: "发送验证码",
    };
  },
  created() {
    // console.log(localStorage.getItem("value"));
    // console.log(this.$store.state.value);
    
  },
  mounted() {},
  methods: {
    //点击发送验证码
    send() {
        // 如果输入框有内容
      if (this.$store.state.value) {
        //   如果手机号码正则通过验证
          if(/^1[3|4|5|7|8][0-9]{9}$/.test(this.$store.state.value)){
              this.$store.commit('changedisabledVerify',false)

            this.$store.commit('changedisabledVerify',false)

             this.content = 60;
            var a = setInterval(() => {
            this.content--;
            if (this.content == 0) {
                clearInterval(a);
                this.content = "获取验证码";
            }
            }, 1000);

          }else{
              this.$loading.show('请输入正确的手机号')
              setTimeout(() => {
              this.$loading.hide()
              },1200)
          }
       
        // 如果输入框没有内容
      } else {
          this.$loading.show('请输入手机号')
              setTimeout(() => {
              this.$loading.hide()
              },1200)
          
      }
    },
  },
  //组件挂载
  components: {},
  //计算属性
  computed: {},
  //过滤器
  filters: {},
};
</script>

<style lang="scss" scoped>
button {
  width: 80px;
  position: absolute;
  top: 284px;
  right: 24px;
}
</style>
